package com.fz.mapper;

import com.fz.entity.Book;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Created by webrx on 2017-09-11.
 */
public interface BookMapper {
    @Select("select * from db_book where id = #{id}")
    public Book queryById(int id);

    @Select("select * from db_book order by id desc")
    public List<Book> queryAll();

    @Insert("insert into db_book values(null,#{name},#{price},#{bdate})")
    public int add(Book book);

    @Insert("insert into db_book values(null,#{name},#{price},#{bdate})")
    public int save(@Param("name") String n,@Param("price") double p,@Param("bdate") String date);

    @Delete("delete from db_book where id=#{id}")
    public int delById(int id);
}
